package org.one.stone.soup.grfxML;

import org.one.stone.soup.mjdb.data.field.DataLinker;
import org.one.stone.soup.mjdb.data.field.Field;
import org.one.stone.soup.mjdb.data.field.LockException;
import org.one.stone.soup.mjdb.data.field.NullField;
import org.one.stone.soup.xml.XmlElement;
  /*
 * Copyright 2000-2001 Wet-Wired.com Ltd.,
 * Portsmouth England
 * All rights reserved.
 */

/**
	*
	* @author Nik Cross
*/
public abstract class DataPlugin extends NullField implements ITag,Plugin{
	public static String DEFAULT_ID="_Plugin";

	protected DataStore data;
	protected DataActionPlugin parent;
	protected XmlElement xml = null;

	private String _path="";
	private boolean _isInitialized = false;

	private GrfxMLEngine engine;

public DataPlugin(GrfxMLEngine engine) {

	this.engine = engine;
	data = new DataStore(engine);
	try{
		setId(DEFAULT_ID,this);
	}
	catch(LockException le){} //Dummy catch
}
public void buildFromgrfxML(XmlElement xml){
}
public void copyFromgrfxML(XmlElement xml){
}
public abstract DataPlugin getClone();
public abstract DataPlugin getClone(String path);
public DataStore getData() {
	return data;
}
/**
 *
 * @return boolean
 */
public boolean getInitialized() {
	return _isInitialized;
}
public String getPath() {
	return _path;
}

public GrfxMLEngine getEngine() {
	return engine;
}

public abstract void initialize();
public abstract void register(DataLinker store);
public abstract void replace(Field oldObj, Field newObj);
public void resetChanged() {
	super.resetChanged();
}
protected void setData(DataStore newData) {
	data = newData;
}
public void setInitialized(boolean new_isInitialized) {
	_isInitialized = new_isInitialized;
}
protected void setPath(String newPath) {
	_path = newPath;
}
public abstract void stop();
public String togrfxML(String name) {
	return toString();
}
public String toString()
{
	if(GrfxMLEngine.DEBUG)
		return(togrfxML( DEFAULT_ID.substring(1) ));

	String xml = "<"+DEFAULT_ID.substring(1)+":"+this.getClass().getName()+" hash=\""+this.hashCode()+"\" />";

	return xml;
}
}
